package com.activitycode.adapter;

import java.util.List;

import com.activitycode.datamodel.OrderList;
import com.activitycode.datamodel.modelinfo.BookHotelInfo;
import com.activitycode.datamodel.modelinfo.OrderInfo;
import com.activitycode.datamodel.modelinfo.SearchInfo;
import com.activitycode.util.CommConstant;
import com.helixinsoft.texi.driver.R;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class OrderAdapter extends BaseAdapter {

	public Context context;
	private List<OrderList> infoList;
	public final String Tag = "HistoryAdapter";
	public OrderAdapter adapter;

	public OrderAdapter(Context ct, List<OrderList> list) {
		this.context = ct;
		this.infoList = list;

		adapter = this;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return infoList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return infoList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder viewHolder = null;

		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.adapter_bookhotel, null);
			viewHolder.subtime = (TextView) convertView
					.findViewById(R.id.adapter_bookhotel_time);
			viewHolder.start = (TextView) convertView
					.findViewById(R.id.adapter_bookhotel_start);
			viewHolder.end = (TextView) convertView
					.findViewById(R.id.adapter_bookhotel_end);
			viewHolder.state = (TextView) convertView
					.findViewById(R.id.adapter_bookhotel_capture);
			convertView.setTag(viewHolder);
			viewHolder.container = (LinearLayout) convertView
				    .findViewById(R.id.orderlist_layout_linear);
		} else {

			viewHolder = (ViewHolder) convertView.getTag();
		}

		viewHolder.subtime.setText(""+infoList.get(position).order_sub_time);
		viewHolder.state.setText(""+infoList.get(position).order_status);
		viewHolder.start.setText(""+infoList.get(position).order_start);
		viewHolder.end.setText(""+infoList.get(position).order_end);

		return convertView;
	}

	public final static class ViewHolder {
		TextView subtime, start, end, state;
		LinearLayout container;
	}

}